<!DOCTYPE html>
<body>
<script src="../../resources/js-test.js"></script>

<div contenteditable id="root">
Foo
</div>
<script>
description('Test key bindings for toggling bold and italic.');
var root = document.getElementById('root');
root.focus();
document.execCommand('SelectAll');
if (!window.eventSender) {
    debug('Try Control-B/Control-I (Command-B/Command-I on Mac) and see if they toggle bold/italic.');
} else {
    shouldBe('root.querySelectorAll("b").length', '0');
    shouldBe('root.querySelectorAll("i").length', '0');
    eventSender.keyDown('b', ['addSelectionKey']);
    shouldBe('root.querySelectorAll("b").length', '1');
    shouldBe('root.querySelectorAll("i").length', '0');
    eventSender.keyDown('i', ['addSelectionKey']);
    shouldBe('root.querySelectorAll("b").length', '1');
    shouldBe('root.querySelectorAll("i").length', '1');
    eventSender.keyDown('b', ['addSelectionKey']);
    shouldBe('root.querySelectorAll("b").length', '0');
    shouldBe('root.querySelectorAll("i").length', '1');
    eventSender.keyDown('i', ['addSelectionKey']);
    shouldBe('root.querySelectorAll("b").length', '0');
    shouldBe('root.querySelectorAll("i").length', '0');
}
</script>
</body>
